package com.lvyq.qrobot.server.remote;

import com.lvyq.qrobot.entity.SysOrder;
import com.lvyq.qrobot.mapper.UserMapper;
import com.lvyq.qrobot.model.receive.ReceiveMsg;
import com.lvyq.qrobot.model.send.SendParam;
import com.lvyq.qrobot.service.SysBarrierService;
import com.lvyq.qrobot.service.SysGovAffairService;
import com.lvyq.qrobot.service.SysOrderService;
import com.lvyq.qrobot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author lvyq
 * @version 1.0
 * Create by 2024-05-31 13:51
 */
@Component
public class RemoteServer {

    public static UserService userService;

    public static UserMapper userMapper;

    public static SysGovAffairService govAffairService;

    public static SysBarrierService sysBarrierService;
    public static SysOrderService sysOrderService;
    @Autowired
    public  void setUserMapper(UserService userService) {
        RemoteServer.userService = userService;
    }

    @Autowired
    public  void setUserService(UserService userService) {
        RemoteServer.userService = userService;
    }

    @Autowired
    public  void setSysOrderService(SysOrderService sysOrderService) {
        RemoteServer.sysOrderService = sysOrderService;
    }

    @Autowired
    public  void setUserMapper(UserMapper userMapper) {
        RemoteServer.userMapper = userMapper;
    }

    @Autowired
    public  void setGovAffairService(SysGovAffairService govAffairService) {
        RemoteServer.govAffairService = govAffairService;
    }

    @Autowired
    public  void setSysBarrierService(SysBarrierService sysBarrierService) {
        RemoteServer.sysBarrierService = sysBarrierService;
    }

    public static void sendMsg(SendParam param, ReceiveMsg vo, String reOrder) {
        //查询指令是否存在
        SysOrder sysOrder = sysOrderService.checkOrderByName(reOrder);
        if (sysOrder !=null ){
            //人员相关
            if (sysOrder.type==0){
                userService.sendMsg(sysOrder,param,vo);
            }
            //政务相关
            if (sysOrder.type==1){
                govAffairService.sendMsg(sysOrder,param,vo);
            }
            //闯关相关
            if (sysOrder.type==2){
                sysBarrierService.sendMsg(sysOrder,param,vo);
            }
        }
    }


}
